home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-12 | 73.0 KB | 2,459 lines |
- /*------------------------------------------------------------------------------
- File: ScriptRunner.cpp
-
- Written by: Sue Dumont (based on SamplePart by Steve Smith)
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Description: ScriptRunner demonstrates the functionality of a
-
- Demonstrates: 1. Open
- 2. Part Drawing
- 3. Refcounting Geometry
- 4. Display Frame 'ternalization
- 5. Part Init & partWrapper
- 6. Persistent Reference
- 7. RefCounting
- 8. Storage Unit
- 9. Activation
- 10. Basic Event Handling
- 11. Windows & Dialogs
- 12. Exception Handling
- 13. Memory Manager
- 14. Using Resources
-
- Notes: • somThis is not set in methods where our internal data members
- are not accessed.
-
- • somInit and somUninit methods behave like C++ constructors
- in that the inherited methods are called automatically. There
- is no need to call the parent class' somInit or somUninit.
- (The macros are there but they do nothing and are just for
- backward compatibility). There also is no need to initialize
- instance variables to zero/NULL in somInit, since SOM guarantees
- that a newly constructed object is zeroed.
- ------------------------------------------------------------------------------*/
-
- // -- Compiler/Preprocessor Notification --
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Special Includes --
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- // -- ScriptRunner Includes
-
- // Notification that this is a SOM source file
- #define SampleCode_ScriptRunner_Class_Source
-
- // define underscore (_) field names
- #define VARIABLE_MACROS
-
- #ifndef _SCRIPTRUNNERDEF_
- #include "ScriptRunnerDef.h"
- #endif
-
- #ifndef _SCRIPTRUNNERGLOBALS_
- #include "ScriptRunnerGlobals.h"
- #endif
-
- #ifndef _SCRIPTRUNNERUTILS_
- #include "ScriptRunnerUtils.h"
- #endif
-
- #ifndef SOM_SampleCode_ScriptRunner_xih
- #include "ScriptRunner.xih"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODFocusSet_xh
- #include <FocusSet.xh>
- #endif
-
- #ifndef SOM_ODFrameFacetIterator_xh
- #include <FrFaItr.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include <ODStor.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdDefs_defined
- #include <StdDefs.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh>
- #endif
-
- #ifndef SOM_ODTypeList_xh
- #include <TypeList.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _ODNEW_
- #include <ODNew.h>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _PLFMDEF_
- #include <PlfmDef.h>
- #endif
-
- #ifndef _PASCLSTR_
- #include <PasclStr.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef _ITEXT_
- #include <IText.h>
- #endif
-
- #ifndef _ISOSTR_
- #include <ISOStr.h>
- #endif
-
- #ifndef _STDTYPIO_
- #include <StdTypIO.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _FOCUSLIB_
- #include <FocusLib.h>
- #endif
-
- #ifndef _USERSRCM_
- #include <UseRsrcM.h>
- #endif
-
- // -- Macintosh Includes --
-
- #ifndef __LOWMEM__
- #include <LowMem.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __ICONS__
- #include <Icons.h> // NewIconSuite, PlotIconSuite, DisposeIconSuite
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
-
- #pragma segment ScriptRunner
-
- //==============================================================================
- // ScriptRunner
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // Static Globals
- //------------------------------------------------------------------------------
-
- static Rect gRecordButton = {8, 7, 33, 42};
- static Rect gStopButton = {8, 51, 32, 86};
- static Rect gRunButton = {8, 95, 33, 130};
- static Rect gCompileButton = {8, 153, 33, 188};
-
-
- //------------------------------------------------------------------------------
- // Method: somInit
- // Origin: SOMObject
- //
- // Description: somInit and somUninit methods behave like C++ constructors
- // in that the inherited methods are called automatically.
- // There is no need to call the parent class' somInit or somUninit.
- //
- // Also, instance variables need not be initialized to 0 or kODNULL
- // since SOM guarantees that a newly constructed object is zeroed out.
- // Warnings: You are not allowed to throw an exception from this method.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__somInit
- (
- SampleCode_ScriptRunner* somSelf
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","somInit");
-
- }
-
- //------------------------------------------------------------------------------
- // Method: somUninit
- // Origin: SOMObject
- //
- // Description: This is the SOM equivalent of a C++ class destructor in this
- // routine, you should clean up any class members which weren't
- // taken care of in the ReleaseAll and Release methods.
- //
- // Warnings: You are not allowed to throw an exception from this method.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__somUninit
- (
- SampleCode_ScriptRunner* somSelf
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","somUninit");
- }
-
- //------------------------------------------------------------------------------
- // Method: Release
- // Origin: ODRefCountedObject
- //
- // Description: This method is called each time an object releases the
- // part. If the refcount falls to 0, the part should
- // release the _fSelf part reference.
- //
- // Warning: If the part releases any other object when the refcount falls
- // to zero, it will need to override the Acquire method so that
- // the object can be referenced again if the parts refcount should
- // be incremented before it is deleted.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__Release
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","Release");
-
- SOM_TRY
- SampleCode_ScriptRunner_parent_ODPart_Release(somSelf, ev);
-
- if ( _fSelf->GetRefCount(ev) == 0 )
- ODGetDraft(ev, _fSelf)->ReleasePart(ev, _fSelf);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: ReleaseAll
- // Origin: ODPersistentObject
- //
- // Description: This method is called just prior to the part being
- // deleted by the Draft. The part must release all
- // references to all refcounted objects it has stored
- // internally; not doing so, will cause an "invalid ref
- // count" exception/error.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ReleaseAll
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ReleaseAll");
-
- SOM_TRY
- // If the last part instance using the globals is released,
- // we need to NULL out the globals.
- if ( --gGlobalsUsageCount == 0 )
- {
- // Release the script source data.
- gGlobals->fOSAScripter->ReleaseScriptData();
-
- ODDeleteObject(gGlobals->fOSAScripter);
- ODRelease(ev, gGlobals->fPaletteExtension);
- ODRelease(ev, gGlobals->fTextTransferExt);
-
- ODDisposeHandle(gGlobals->fFloatWindowProc);
- ODDisposeHandle(gGlobals->fDisabledRecButton);
-
- if ( gGlobals->fResultValue )
- ODDisposePtr(gGlobals->fResultValue);
-
- DisposeHandle(gGlobals->fPalette);
-
- // Delete the globals struct.
- ODDeleteObject(gGlobals);
- }
-
- SampleCode_ScriptRunner_parent_ODPart_ReleaseAll(somSelf, ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Purge
- // Origin: ODObject
- //
- // Description: This method is called when the draft runs out of memory;
- // when a part is being deleted; or during the creation of
- // stationery. The part should free up as much memory as possible.
- //------------------------------------------------------------------------------
- SOM_Scope ODSize
- SOMLINK ScriptRunner__Purge
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODSize /* size */
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","Purge");
-
- return 0;
- }
-
- //------------------------------------------------------------------------------
- // Method: InitPart
- // Origin: ODPart
- //
- // Description: The ScriptRunnerAgent object calls the draft's CreatePart
- // method, which in turn calls the InitPart method to create
- // and initialize the ScriptRunner part.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__InitPart
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODStorageUnit* storageUnit,
- ODPart* partWrapper
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","InitPart");
-
- SOM_TRY
- // We must call the initialize method of our parent class
- // to allow OpenDoc to annotate our part's storageUnit, and
- // to set our refcount.
- SampleCode_ScriptRunner_parent_ODPart_InitPart(somSelf, ev, storageUnit, partWrapper);
-
- // To allow editor swapping (translation) at runtime, OpenDoc requires
- // Store a "reference" to ourself. We'll need this when interacting with
- // the OpenDoc API (ie. WindowState::RegisterWindow(),
- // Dispatcher::RegisterIdle, etc). The "partWrapper" passed to us here
- // is the "reference" OpenDoc wants us to use.
- _fSelf = partWrapper;
-
- // NOTE: This code is present to support the Shell during stationery
- // creation, which is pointless for this part.
- somSelf->CheckAndAddProperties(ev, storageUnit);
-
- // Call the common initialization code to get set up.
- somSelf->Initialize(ev, storageUnit);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: InitPartFromStorage
- // Origin: ODPart
- //
- // Description: This method is called when a document/stationery is
- // being opened or when the part is internalized by its
- // containing part. The part should merely read in its
- // saved state/content and initialize itself. The part
- // must not alter its storage unit; otherwise, the "Save"
- // menu item becomes enabled without the user actually
- // having made a change to the document.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__InitPartFromStorage
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODStorageUnit* storageUnit,
- ODPart* partWrapper
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","InitPartFromStorage");
-
- SOM_TRY
- SampleCode_ScriptRunner_parent_ODPart_InitPartFromStorage(somSelf, ev,
- storageUnit, partWrapper);
- _fSelf = partWrapper;
- somSelf->Initialize(ev, storageUnit);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Initialize
- // Origin: ScriptRunner
- //
- // Description: This method is called during the internalization of the part
- // from a document. Its purpose is to initialize all fields of
- // the part and to convert ISO types to tokens for faster
- // comparisons throughout the code.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__Initialize
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODStorageUnit* storageUnit
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","Initialize");
-
- SOM_TRY
-
- ODSession* session = ODGetSession(ev, storageUnit);
-
- // Check to see if we need to initialize our globals.
-
- if ( gGlobalsUsageCount == 0 )
- {
- // Create our globals space. We store the globals in a struct so
- // that we can put them in temp mem. Otherwise, CFM loads the globals
- // with the data fragment of a CFM library in the application heap.
- gGlobals = new ScriptRunnerGlobals;
-
- // Load our floating window def proc in case the 7.5 def proc
- // isn't available.
- ODSLong savedRef = BeginUsingLibraryResources();
- {
- gGlobals->fFloatWindowProc = GetResource('WDEF', kFloatWindowDefID);
- DetachResource(gGlobals->fFloatWindowProc);
-
- // Since this version doesn't support recording, load the disabled
- // Record button.
- gGlobals->fDisabledRecButton = (ODHandle)GetPicture(kRecordDisabledID);
- DetachResource(gGlobals->fDisabledRecButton);
- }
- EndUsingLibraryResources(savedRef);
-
- // We will be using only the modal focus in this part. For
- // convenience, we tokenize the value here and store it for
- // equivalence tests in the activation methods.
- gGlobals->fModalFocus = session->Tokenize(ev, kODModalFocus);
-
- // Tokenize our two presentation values, and the frame view type.
- gGlobals->fPalettePresentation = session->Tokenize(ev, kPalettePresentation);
- gGlobals->fResultPresentation = session->Tokenize(ev, kResultPresentation);
- gGlobals->fFrameView = session->Tokenize(ev, kODViewAsFrame);
-
- // Get the platform value type for 'TEXT' data from OpenDoc. We
- // use this when Dragging the Result from the result window.
- gGlobals->fTextKind = session->GetTranslation(ev)->
- GetISOTypeFromPlatformType(ev, typeChar, kODPlatformDataType);
-
- // Instantiate the OSA helper object and open a connection
- // for the scripting component.
- gGlobals->fOSAScripter = new CScripter;
- _fScriptConnection = gGlobals->fOSAScripter->OpenScriptingComponent();
-
- // Set the bounds for the palette and result windows.
- SetRect(&gGlobals->fPaletteBounds, kPaletteOrigin, kPaletteOrigin,
- kPaletteOrigin+kPaletteWidth, kPaletteOrigin+kPaletteHeight);
- SetRect(&gGlobals->fResultBounds, kResultOrigin, kResultOrigin,
- kResultOrigin+kResultWidth, kResultOrigin+kResultHeight);
-
- // The first client of the global variables is running.
- gGlobalsUsageCount = 1;
- }
- else
- {
- // We keep a "usage" count so that we can null out
- // the global variables when we are finished using them.
- gGlobalsUsageCount++;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: HasExtension
- // Origin: ODObject
- //
- // Description: Returns true if asking for the Palette Extension.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__HasExtension
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODType extensionName
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HasExtension");
-
- return ( ODISOStrEqual(extensionName, kPaletteExtension) );
- }
-
- //------------------------------------------------------------------------------
- // Method: AcquireExtension
- // Origin: ODObject
- //------------------------------------------------------------------------------
- SOM_Scope ODExtension*
- SOMLINK ScriptRunner__AcquireExtension
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODType extensionName
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","AcquireExtension");
-
- SOM_TRY
- if ( ODISOStrEqual(extensionName, kPaletteExtension) )
- {
- if ( gGlobals->fPaletteExtension == kODNULL )
- {
- gGlobals->fPaletteExtension = new Samples_PaletteExt;
- gGlobals->fPaletteExtension->InitExtension(ev, _fSelf);
- }
-
- ODAcquireObject(ev, gGlobals->fPaletteExtension);
- }
- SOM_CATCH_ALL
- ODSafeReleaseObject(gGlobals->fPaletteExtension);
- gGlobals->fPaletteExtension = kODNULL;
- SOM_ENDTRY
-
- return gGlobals->fPaletteExtension;
- }
-
- //------------------------------------------------------------------------------
- // Method: ReleaseExtension
- // Origin: ODObject
- //
- // Description: This method is called when the extension's refcount
- // reaches zero. At this point, we delete the object.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ReleaseExtension
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODExtension* extension
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ReleaseExtension");
-
- SOM_TRY
- if ( ODObjectsAreEqual(ev, extension, gGlobals->fPaletteExtension) )
- ODDeleteObject(gGlobals->fPaletteExtension);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: CheckAndAddProperties
- // Origin: ScriptRunner
- //
- // Description: This method is called to prepare the storage unit
- // during the creation of stationery, and to verify
- // that all the properties we need are present during
- // externalization. .
- //
- // The part typically adds the default content property,
- // a preferred editor/viewer property (to aid in part binding),
- // and a default name for the part.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__CheckAndAddProperties
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODStorageUnit* storageUnit
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CheckAndAddProperties");
-
- SOM_TRY
- // Create our content property.
- if ( !storageUnit->Exists(ev, kODPropContents, kODNULL, 0) )
- storageUnit->AddProperty(ev, kODPropContents);
- if ( !storageUnit->Exists(ev, kODPropContents, kScriptRunnerKind, 0) )
- {
- storageUnit->Focus(ev, kODPropContents, kODPosUndefined, kODNULL,
- 0, kODPosUndefined);
- storageUnit->AddValue(ev, kScriptRunnerKind);
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Open
- // Origin: ODPart
- //
- // Description: Typically, this method is called when OpenDoc, a containing
- // part, or the active editor/viewer would like to open a frame
- // into a seperate window. If a source frame is passed into
- // this method, the editor/viewer is being asked to open a
- // part window.
- //
- // However, for the ScriptRunner part, this method is called
- // by the ScriptRunnerAgent object, after it created this part.
- //------------------------------------------------------------------------------
- SOM_Scope ODID
- SOMLINK ScriptRunner__Open
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","Open");
-
- SOM_TRY
- if ( frame == kODNULL )
- {
- Str63 windowTitle;
-
- // Get the window title string from our library's resources.
- // (Note: ODGetIndString focuses the resource fork for us)
- ODGetIndString(windowTitle, kStringResID, kScriptRunnerIndex);
-
- // Create the floating palette window.
- TempODWindow window = somSelf->CreateWindow(ev, gGlobals->fPalettePresentation,
- floatProc, windowTitle, &gGlobals->fPaletteBounds);
- THROW_IF_NULL(window);
-
- somSelf->LoadPalette(ev);
- window->Open(ev);
- gGlobals->fPaletteID = window->GetID(ev);
- }
- else
- THROW(kODErrInvalidFrame);
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return gGlobals->fPaletteID;
- }
-
- //------------------------------------------------------------------------------
- // Method: Draw
- // Origin: ODPart
- //
- // Description: This method is called when a facet of a part's display
- // frame intersects the invalidated portion of an OpenDoc
- // window. The invalidShape parameter passed in is the
- // portion of the facet which has been invalidated.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__Draw
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFacet* facet,
- ODShape* invalidShape
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner", "Draw");
-
- SOM_TRY
- ODFrame* frame = facet->GetFrame(ev);
-
- if ( frame->GetPresentation(ev) == gGlobals->fPalettePresentation &&
- gGlobals->fPaletteVisible )
- {
- // Focus the port and origin for drawing in our facet. Note that
- // this instance of the CFocus class is being allocated. When the
- // execution leaves the scope of this method, the destructor is
- // automatically called and cleans up the drawing environment.
- CFocus initiateDrawing(ev, facet);
-
- TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
- RgnHandle rgn = frameShape->GetQDRegion(ev);
- Rect bounds = (**rgn).rgnBBox;
-
- DrawPicture((PicHandle)gGlobals->fPalette, &bounds);
-
- // Draw the "disabled" Recording button (for now).
- DrawPicture((PicHandle)gGlobals->fDisabledRecButton, &gRecordButton);
- }
- else if ( gGlobals->fResultWindowVisible )
- {
- somSelf->DisplayResult(ev);
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameAdded
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame being
- // created for our part.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__DisplayFrameAdded
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","DisplayFrameAdded");
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameRemoved
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame being
- // removed from our part and the draft.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__DisplayFrameRemoved
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","DisplayFrameRemoved");
-
- SOM_TRY
- ODArbitrator* arbitrator = ODGetSession(ev, _fSelf)->GetArbitrator(ev);
-
- // Make sure the frame going away doesn't own any foci. Forgetting
- // to do this will cause a "refcounting" error when the frame
- // is deleted by the draft.
- TempODFrame focusFrame = arbitrator->AcquireFocusOwner(ev, gGlobals->fModalFocus);
- if ( ODObjectsAreEqual(ev, focusFrame, frame) )
- arbitrator->RelinquishFocus(ev, gGlobals->fModalFocus, frame);
-
- // Clean up the window associated with this frame.
- TempODWindow window = frame->AcquireWindow(ev);
- THROW_IF_NULL(window);
-
- ODPlatformWindow windowPtr = window->GetPlatformWindow(ev);
- CloseWindow(windowPtr);
- ODDisposePtr(windowPtr);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameClosed
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame being
- // closed but not removed from the draft.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__DisplayFrameClosed
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","DisplayFrameClosed");
-
- SOM_TRY
- ODArbitrator* arbitrator = ODGetSession(ev, _fSelf)->GetArbitrator(ev);
-
- TempODFrame focusFrame = arbitrator->AcquireFocusOwner(ev, gGlobals->fModalFocus);
- if ( ODObjectsAreEqual(ev, focusFrame, frame) )
- arbitrator->RelinquishFocus(ev, gGlobals->fModalFocus, frame);
-
- // Clean up the window associated with this frame.
- TempODWindow window = frame->AcquireWindow(ev);
- THROW_IF_NULL(window);
-
- ODPlatformWindow windowPtr = window->GetPlatformWindow(ev);
- CloseWindow(windowPtr);
- ODDisposePtr(windowPtr);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameConnected
- // Origin: ODPart
- //
- // Description: This method is called when one of our display frames,
- // previously written out, is internalized. This method
- // is called instead of DisplayFrameAdded because a "new"
- // frame is not being created; an existing one is being
- // reconstituted.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__DisplayFrameConnected
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","DisplayFrameConnected");
-
- // This method never gets called since we don't externalize
- // our display frames, but must be overridden.
- }
-
- //------------------------------------------------------------------------------
- // Method: ViewTypeChanged
- // Origin: ODPart
- //
- // Description: This method is called when one of our display frame's
- // viewType field has been modified. We call this
- // method on ourselves when new display frames are
- // added, but it can also be called when the user
- // changes the view in the "part info" dialog.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ViewTypeChanged
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ViewTypeChanged");
-
- SOM_TRY
- // ScriptRunner only allows "frame" view.
- if ( frame->GetViewType(ev) != gGlobals->fFrameView )
- frame->SetViewType(ev, gGlobals->fFrameView);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: BeginRelinquishFocus
- // Origin: ODPart
- //
- // Description: This method is called when another part (or possibly
- // ourself) is requesting a focus for one of its display
- // frames. Returning true means we are willing to give
- // up the requested focus.
- //
- // The part will give up any focus except for the
- // modal focus. We don't want to give this up until we
- // are completely done displaying a modal dialog.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__BeginRelinquishFocus
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeToken focus,
- ODFrame* /*ownerFrame*/,
- ODFrame* proposedFrame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","BeginRelinquishFocus");
-
- ODBoolean willRelinquish = kODTrue;
-
- SOM_TRY
- // Another part is trying to put up a Modal dialog while we
- // are currently displaying ours. Deny the request.
- if ( focus == gGlobals->fModalFocus )
- {
- TempODPart proposedPart = proposedFrame->AcquirePart(ev);
- if ( ODObjectsAreEqual(ev, proposedPart, _fSelf) == kODFalse )
- willRelinquish = kODFalse;
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return willRelinquish;
- }
-
- //------------------------------------------------------------------------------
- // Method: CommitRelinquishFocus
- // Origin: ODPart
- //
- // Description: This method is called when it is actually time to give
- // up the requested focus.
- //
- // The part calls its FocusLost method to handle the
- // reliquishing of the particular focus.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__CommitRelinquishFocus
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CommitRelinquishFocus");
-
- SOM_TRY
- // We agreed to give up the requested focus, so now we must do so.
- somSelf->FocusLost(ev, focus, ownerFrame);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: AbortRelinquishFocus
- // Origin: ODPart
- //
- // Description: This method is called when another part (or ourself) requested
- // a focus for one of its display frames, bet we returned kODFalse
- // from BeginRelinqishFocus() for one, or all, of the requested
- // foci. At this point, we are being told to resume ownership of
- // the focus.
- //
- // The part calls its FocusAcquired method to handle the
- // re-acquisition of the particular focus.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__AbortRelinquishFocus
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* /*proposedFrame*/
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","AbortRelinquishFocus");
-
- // Some parts may have suspended some events in the BeginRelinquishFocus
- // method. If so, they would resume those events here.
- }
-
- //------------------------------------------------------------------------------
- // Method: FocusAcquired
- // Origin: ODPart
- //
- // Description: This method is called when the Arbitrator has
- // registered us as the "owner" of the particular focus.
- // This can occur if a focus is requested, or if a focus
- // is tranferred to one of the part's display frames.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__FocusAcquired
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeToken focus,
- ODFrame* ownerFrame
- )
-
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","FocusAcquired");
- }
-
- //------------------------------------------------------------------------------
- // Method: FocusLost
- // Origin: ODPart
- //
- // Description: This method is called when the Arbitrator has
- // unregistered us as the owner of a particular focus.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__FocusLost
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeToken focus,
- ODFrame* ownerFrame
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","FocusLost");
- }
-
- //------------------------------------------------------------------------------
- // Method: HandleEvent
- // Origin: ODPart
- //
- // Description: The method is called when an event occurs within one of
- // our owned foci. The exception to this case are "mouse
- // movement" events and embedded frame events, which can occur
- // when a part owns no foci.
- //
- // The part returns true if the event was handled.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__HandleEvent
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODEventData* event,
- ODFrame* frame,
- ODFacet* facet,
- ODEventInfo* eventInfo
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HandleEvent");
-
- ODBoolean eventHandled = kODFalse;
-
- SOM_TRY
- // Event handling is basically the same as standard
- // Macintosh applications, except that the events have
- // been renamed for cross-platform compatability.
-
- switch( event->what )
- {
- case kODEvtMouseUp:
- case kODEvtMouseDown:
- eventHandled = somSelf->HandleMouseEvent(ev, event,
- eventInfo, frame, facet);
- break;
-
- case kODEvtWindow:
- eventHandled = somSelf->HandleWindowEvent(ev, event, frame);
- break;
-
- default:
- break;
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return eventHandled;
- }
-
- //------------------------------------------------------------------------------
- // Method: HandleOSAEvent
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__HandleOSAEvent
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame,
- ODCommandID command
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HandleOSAEvent");
-
- ODByteArray data;
-
- SOM_TRY
- switch( command )
- {
- case kRecordCommand:
- // Not handled yet.
- break;
-
- case kStopCommand:
- break;
-
- case kRunCommand:
- // Dispose of the result value before executing a new script.
- if ( gGlobals->fResultValue != kODNULL )
- {
- ODDisposePtr(gGlobals->fResultValue);
- gGlobals->fResultValue = kODNULL;
- }
-
- if ( gGlobals->fTextTransferExt->GetData(ev, typeChar, &data) )
- {
- TRY
- gGlobals->fOSAScripter->SetScriptSourceBA(typeChar, &data);
- gGlobals->fOSAScripter->DoRun();
- CATCH_ALL
- DisposeByteArrayStruct(data);
- RERAISE;
- ENDTRY
- DisposeByteArrayStruct(data);
-
- somSelf->SetClientTextData(ev);
- somSelf->DisplayResult(ev);
- }
- break;
-
- case kCompileCommand:
- if ( gGlobals->fTextTransferExt->GetData(ev, typeChar, &data) )
- {
- TRY
- gGlobals->fOSAScripter->SetScriptSourceBA(typeChar, &data);
- gGlobals->fOSAScripter->DoCompile();
- CATCH_ALL
- DisposeByteArrayStruct(data);
- RERAISE;
- ENDTRY
- DisposeByteArrayStruct(data);
-
- somSelf->SetClientTextData(ev);
- }
- break;
-
- default:
- break;
- }
- SOM_CATCH_ALL
- somSelf->DoErrorDialog(ev, frame);
- // Change the error code value so the DocShell doesn't
- // display an error dialog.
- SetErrorCode(kODErrAlreadyNotified);
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: HandleWindowEvent
- // Origin: ScriptRunner
- //
- // Description: This method is called by the part to handle window events.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__HandleWindowEvent
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODEventData* event,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HandleWindowEvent");
-
- ODBoolean handled = kODFalse;
-
- SOM_TRY
- switch( event->message )
- {
- case inGoAway:
- if ( frame->GetPresentation(ev) == gGlobals->fPalettePresentation )
- somSelf->HidePalette(ev);
- else
- somSelf->HideResultWindow(ev);
-
- handled = kODTrue;
- break;
-
- default:
- break;
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return handled;
- }
-
- //------------------------------------------------------------------------------
- // Method: HandleMouseEvent
- // Origin: ScriptRunner
- //
- // Description: This method is called when a mouse event is received.
- // When a frame is inactive, the first mouse up event
- // activates it (inactive frames do not receive
- // kODEvtMouseDown events).
- //
- // The mouse down event is handled in the Result window
- // to determine if the user is dragging the result value.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__HandleMouseEvent
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODEventData* event,
- ODEventInfo* eventInfo,
- ODFrame* frame,
- ODFacet* facet
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HandleMouseEvent");
-
- SOM_TRY
- // If the facet parameter is invalid, the mouse up occurred outside the
- // bounds of a Modal window, otherwise it should be treated normally.
- if ( facet != kODNULL )
- {
- if ( event->what == kODEvtMouseUp )
- {
- ODWindow* window = facet->GetWindow(ev);
-
- // Activate inactive windows on the first mouse up event.
- if ( !window->IsActive(ev) )
- window->Select(ev);
- else
- somSelf->HandleMouseUp(ev, eventInfo, frame);
- }
- else if ( event->what == kODEvtMouseDown )
- {
- // Check which window the mouse event occurred in.
- if ( frame->GetPresentation(ev) == gGlobals->fPalettePresentation )
- somSelf->HandleMouseDown(ev, eventInfo, facet);
- else
- {
- if ( WaitMouseMoved(event->where) )
- somSelf->InitiateDrag(ev, event, facet, &(eventInfo->where));
- }
- }
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return kODTrue;
- }
-
- //------------------------------------------------------------------------------
- // Method: HandleMouseUp
- // Origin: ScriptRunner
- //
- // Description: This method is called by the part when a mouse event
- // is recieved.
- //
- // If the user mouses up in the controls palette over an
- // active button, perform the corresponding action.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__HandleMouseUp
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODEventInfo* eventInfo,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HandleMouseUp");
-
- Rect buttonRect;
- Point where;
-
- SOM_TRY
- // Get the localized mouse coordinates from the Event Info.
- where.h = FixedToInt(eventInfo->where.x);
- where.v = FixedToInt(eventInfo->where.y);
-
- if ( PtInRect(where, &gStopButton) && (_fButton == kStopCommand) )
- somSelf->HandleOSAEvent(ev, frame, kStopCommand);
- else if ( PtInRect(where, &gRunButton) && (_fButton == kRunCommand) )
- somSelf->HandleOSAEvent(ev, frame, kRunCommand);
- else if ( PtInRect(where, &gCompileButton) && (_fButton == kCompileCommand) )
- somSelf->HandleOSAEvent(ev, frame, kCompileCommand);
-
- ODBoolean refreshButtons = kODTrue;
-
- // The button that was pressed must be the one that is refreshed
- switch ( _fButton )
- {
- case kRecordCommand: buttonRect = gRecordButton;
- break;
-
- case kStopCommand: buttonRect = gStopButton;
- break;
-
- case kRunCommand: buttonRect = gRunButton;
- break;
-
- case kCompileCommand: buttonRect = gCompileButton;
- break;
-
- default: refreshButtons = kODFalse;
- }
-
- // Invalidate the button that was pressed.
- if ( refreshButtons )
- InvalidateRect(ev, frame, buttonRect);
-
- _fButton = kODNULLID;
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: HandleMouseDown
- // Origin: ScriptRunner
- //
- // Description: This method is called by the part when a mouse event
- // is received.
- //
- // If the controls palette is showing, the mouse downs
- // are handled on the buttons.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__HandleMouseDown
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODEventInfo* eventInfo,
- ODFacet* facet
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HandleMouseDown");
-
- Rect buttonRect;
- PicHandle buttonPICT;
- Point where;
- ODUShort buttonID = kODNULLID;
-
- SOM_TRY
- // Get the localized mouse coordinates from the Event Info.
- where.h = FixedToInt(eventInfo->where.x);
- where.v = FixedToInt(eventInfo->where.y);
-
- if ( PtInRect(where, &gStopButton) )
- {
- _fButton = kStopCommand;
- buttonID = kStopPressedID;
- buttonRect = gStopButton;
- }
- else if ( PtInRect(where, &gRunButton) )
- {
- _fButton = kRunCommand;
- buttonID = kRunPressedID;
- buttonRect = gRunButton;
- }
- else if ( (PtInRect(where, &gCompileButton)) )
- {
- _fButton = kCompileCommand;
- buttonID = kCompilePressedID;
- buttonRect = gCompileButton;
- }
-
- // If valid, draw the control button in its "pressed" state.
- if ( buttonID )
- {
- CUsingLibraryResources res;
-
- CFocus initiateDrawing(ev, facet);
- buttonPICT = GetPicture(buttonID);
- DrawPicture(buttonPICT, &buttonRect);
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: CreateWindow
- // Origin: ScriptRunner
- //
- // Description: This method is called by the palette extension when the
- // palette window needs to be created.
- //------------------------------------------------------------------------------
- SOM_Scope ODWindow*
- SOMLINK ScriptRunner__CreateWindow
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeToken presentation,
- ODSShort procID,
- Str63 windowTitle,
- Rect* windowBounds
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CreateWindow");
-
- ODPlatformWindow platformWindow = kODNULL;
- ODWindow* window = kODNULL;
- ODBoolean resizeable;
-
- ODVolatile(platformWindow);
-
- SOM_TRY
-
- ODPtr wStorage = ODNewPtr(sizeof(WindowRecord));
- // Create the floating palette with the 7.5 window proc.
- platformWindow = NewCWindow(wStorage,
- windowBounds,
- windowTitle,
- kODFalse, // visible flag
- procID,
- (WindowPtr)-1L,
- kODTrue,
- kODNULL);
-
- if ( platformWindow == kODNULL && procID == floatProc )
- {
- // If NewCWindow returned NULL when trying to create a floating
- // window, then we may be running on a pre-7.5 system.
- platformWindow = NewCWindow(wStorage,
- windowBounds,
- windowTitle,
- kODFalse,
- kFloatWindowDefID * 16,
- (WindowPtr)-1L,
- kODTrue,
- kODNULL);
-
- // Substitute our window proc for the 7.5 window proc that was loaded..
- if ( platformWindow )
- {
- Handle tempProc = ((WindowPeek)platformWindow)->windowDefProc;
- ((WindowPeek)platformWindow)->windowDefProc = gGlobals->fFloatWindowProc;
- ReleaseResource(tempProc);
- }
- }
-
- if ( platformWindow )
- {
- resizeable = (presentation == gGlobals->fPalettePresentation) ? kODFalse : kODTrue;
- ODWindowState* windowState = ODGetSession(ev, _fSelf)->GetWindowState(ev);
-
- // Tell OpenDoc about it by creating an OpenDoc window object.
- window = windowState->RegisterWindow(ev,
- platformWindow, // Macintosh WindowPtr
- kODNonPersistentFrameObject, // Frame type (Persistent/Non-persistent)
- kODFalse, // Is this a document/root window?
- resizeable, // Is this window resizeable?
- kODTrue, // Is this window floating?
- kODFalse, // Should this window be persistent?
- kODFalse, // Should this window be disposed?
- _fSelf, // Part reference to us
- gGlobals->fFrameView, // What view should the window have?
- presentation, // The presentation the window should have.
- kODNULL); // The display frame being opened, if any
- }
-
- SOM_CATCH_ALL
- if ( platformWindow )
- {
- // Cleanup Macintosh Window.
- CloseWindow(platformWindow);
- ODDisposePtr(platformWindow);
- }
- SOM_ENDTRY
-
- return window;
- }
-
- //------------------------------------------------------------------------------
- // Method: AcquireWindowByID
- // Origin: ScriptRunner
- //
- // Description: Return the palette window.
- //------------------------------------------------------------------------------
- SOM_Scope ODWindow*
- SOMLINK ScriptRunner__AcquireWindowByID
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODID windowID
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","AcquireWindowByID");
-
- ODWindow* window;
-
- SOM_TRY
- window = ODGetSession(ev, _fSelf)->GetWindowState(ev)
- ->AcquireWindow(ev, windowID);
- SOM_CATCH_ALL
- window = kODNULL;
- SOM_ENDTRY
-
- return window;
- }
-
- //------------------------------------------------------------------------------
- // Method: SetClient
- // Origin: ScriptRunner
- //
- // Description: The client part has changed to another part of the
- // same type.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__SetClient
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODPart* client
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","SetClient");
-
- SOM_TRY
- if ( !ODObjectsAreEqual(ev, client, gGlobals->fClient) )
- {
- if ( gGlobals->fTextTransferExt )
- ODReleaseObject(ev, gGlobals->fTextTransferExt);
-
- if ( client->HasExtension(ev, kTextTransferExtension) )
- {
- // Acquire the Text Transfer Extension.
- gGlobals->fTextTransferExt = (TextTransferExt*)client
- ->AcquireExtension(ev, kTextTransferExtension);
- }
-
- gGlobals->fClient = client;
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: SetClientTextData
- // Origin: ScriptRunner
- //
- // Description: After compiling/executing a script, set the text data of
- // the client.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__SetClientTextData
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","SetClientTextData");
-
- ODByteArray textData;
- ODBoolean successful;
-
- SOM_TRY
- gGlobals->fOSAScripter->DoDecompile();
-
- // First try setting the client's text to reflect the styled text
- // of a compiled script.
- if ( gGlobals->fOSAScripter->GetScriptSourceBA('stxt', &textData) )
- {
- successful = gGlobals->fTextTransferExt->SetData(ev, 'stxt', &textData);
- DisposeByteArrayStruct(textData);
- }
-
- // Styled text failed. Try plain text.
- if ( !successful )
- {
- if ( gGlobals->fOSAScripter->GetScriptSourceBA(typeChar, &textData) )
- {
- gGlobals->fTextTransferExt->SetData(ev, typeChar, &textData);
- DisposeByteArrayStruct(textData);
- }
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: MovePalette
- // Origin: ScriptRunner
- //
- // Description: This method is called by the palette extension to
- // position the palette window to the point passed in.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__MovePalette
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODPoint* point
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","MovePalette");
-
- ODBoolean result = kODFalse;
- ODSShort left = point->x;
- ODSShort top = point->y;
-
- ODWindow* window = somSelf->AcquireWindowByID(ev, gGlobals->fPaletteID);
- if ( window )
- {
- SetRect(&gGlobals->fPaletteBounds, left, top, left+kPaletteWidth, top+kPaletteHeight);
- MoveWindow((WindowPtr)window, left, top, kODFalse);
- ODReleaseObject(ev, window);
- result = kODTrue;
- }
-
- return result;
- }
-
- //------------------------------------------------------------------------------
- // Method: GetPaletteLocation
- // Origin: ScriptRunner
- //
- // Description: Returns the top left corner of the palette window.
- //------------------------------------------------------------------------------
- SOM_Scope ODPoint*
- SOMLINK ScriptRunner__GetPaletteLocation(SampleCode_ScriptRunner *somSelf, Environment *ev)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","GetPaletteLocation");
-
- ODPoint* pt = kODNULL;
-
- ODVolatile(pt);
-
- SOM_TRY
- // Allocate and set the point coordinates.
- pt = new ODPoint;
- pt->x = gGlobals->fPaletteBounds.left;
- pt->y = gGlobals->fPaletteBounds.top;
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return pt;
- }
-
- //------------------------------------------------------------------------------
- // Method: LoadPalette
- // Origin: ScriptRunner
- //
- // Description: This method is called by the part to load its control palette.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__LoadPalette
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","LoadPalette");
-
- SOM_TRY
- ODSLong savedRef = BeginUsingLibraryResources();
- {
- gGlobals->fPalette = (Handle)GetPicture(kControlsID);
- DetachResource(gGlobals->fPalette);
- }
- EndUsingLibraryResources(savedRef);
-
- // If we were unable to load the PICT resource for whatever reason,
- // we will throw the Resource Manager error as an exception.
-
- if ( gGlobals->fPalette == kODNULL )
- {
- // There is a bug in ResError, when resources are not found,
- // which may cause noErr to be returned. If that is the case,
- // we throw resNotFound.
- THROW_IF_ERROR((ODError)ResError());
- THROW(resNotFound);
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: IsPaletteVisible
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__IsPaletteVisible
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner", "IsPaletteVisible");
-
- return gGlobals->fPaletteVisible;
- }
-
- //------------------------------------------------------------------------------
- // Method: ShowPalette
- // Origin: ScriptRunner
- //
- // Description: This method is called by the palette extension to show
- // the scripting palette.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ShowPalette
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ShowPalette");
-
- SOM_TRY
- if ( !gGlobals->fPaletteVisible )
- {
- TempODWindow window = somSelf->AcquireWindowByID(ev, gGlobals->fPaletteID);
- THROW_IF_NULL(window);
-
- // Make the window visible.
- window->Show(ev);
- gGlobals->fPaletteVisible = kODTrue;
-
- if ( gGlobals->fResultHidden )
- {
- somSelf->DisplayResult(ev);
- gGlobals->fResultHidden = kODFalse;
- }
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: HidePalette
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__HidePalette
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner", "HidePalette");
-
- SOM_TRY
- if ( gGlobals->fPaletteVisible )
- {
- TempODWindow window = somSelf->AcquireWindowByID(ev, gGlobals->fPaletteID);
- // If we don't have a window, then something is wrong
- THROW_IF_NULL(window);
-
- // Hide the palette window.
- window->Hide(ev);
- gGlobals->fPaletteVisible = kODFalse;
-
- if ( gGlobals->fResultWindowVisible )
- {
- // Also hide the Result window and set its flag.
- somSelf->HideResultWindow(ev);
- gGlobals->fResultHidden = kODTrue;
- }
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: IsResultWindowVisible
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK ScriptRunner__IsResultWindowVisible
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner", "IsResultWindowVisible");
-
- return gGlobals->fResultWindowVisible;
- }
-
- //------------------------------------------------------------------------------
- // Method: CreateResultWindow
- // Origin: ScriptRunner
- //
- // Description: This method is called by the palette extension to show
- // the scripting palette.
- //------------------------------------------------------------------------------
- SOM_Scope ODWindow*
- SOMLINK ScriptRunner__CreateResultWindow
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CreateResultWindow");
-
- ODWindow* window; // Released by the caller.
-
- SOM_TRY
- Str63 windowTitle;
-
- // Get the window title string from our library's resources.
- // (Note: ODGetIndString focuses the resource fork for us)
- ODGetIndString(windowTitle, kStringResID, kResultsIndex);
-
- // The Result window hasn't been created yet; create it.
- window = somSelf->CreateWindow(ev, gGlobals->fResultPresentation,
- floatGrowProc, windowTitle, &gGlobals->fResultBounds);
- THROW_IF_NULL(window);
-
- // Create the facet hierarchy for this window.
- window->Open(ev);
- gGlobals->fResultID = window->GetID(ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return window;
- }
-
- //------------------------------------------------------------------------------
- // Method: ShowResultWindow
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope ODWindow*
- SOMLINK ScriptRunner__ShowResultWindow
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner", "ShowResultWindow");
-
- ODWindow* window = kODNULL;
-
- ODVolatile(window);
-
- SOM_TRY
- if ( gGlobals->fResultID == kODNULLID )
- window = somSelf->CreateResultWindow(ev);
- else
- window = somSelf->AcquireWindowByID(ev, gGlobals->fResultID);
-
- THROW_IF_NULL(window);
-
- if ( !gGlobals->fResultWindowVisible )
- {
- // Show the Result window.
- window->Show(ev);
- gGlobals->fResultWindowVisible = kODTrue;
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return window;
- }
-
- //------------------------------------------------------------------------------
- // Method: HideResultWindow
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__HideResultWindow
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner", "HideResultWindow");
-
- SOM_TRY
- if ( gGlobals->fResultWindowVisible )
- {
- TempODWindow window = somSelf->AcquireWindowByID(ev, gGlobals->fResultID);
- // If we don't have a window, then something is wrong
- THROW_IF_NULL(window);
-
- // Hide the Result window.
- window->Hide(ev);
- gGlobals->fResultWindowVisible = kODFalse;
- }
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayResult
- // Origin: ScriptRunner
- //
- // Description: This method displays the result after script execution.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__DisplayResult
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","DisplayResult");
-
- GrafPtr thePort;
- Rect bounds;
-
- SOM_TRY
- TempODWindow window = somSelf->ShowResultWindow(ev);
- THROW_IF_NULL(window);
-
- if ( gGlobals->fResultValue == kODNULL )
- {
- gGlobals->fResultValue = gGlobals->fOSAScripter->GetResultAsText(ev);
- if ( !gGlobals->fResultValue )
- {
- Str63 text;
- // Get the "< no result >" string from our library's resources.
- // (note: ODGetIndString focuses the resource fork for us)
- ODGetIndString(text, kStringResID, kNoResultIndex);
-
- ODSShort length = text[0];
- gGlobals->fResultValue = (ODISOStr) ODNewPtr(length + 1);
- ODISOStrNCopy(gGlobals->fResultValue, (ODISOStr)text+1, length);
- ((char*)gGlobals->fResultValue)[length] = '\0';
- }
- }
-
- ODFacet* facet = window->GetRootFacet(ev);
- // Focus the port and origin for drawing in our facet. Note that
- // this instance of the CFocus class is being allocated. When the
- // execution leaves the scope of this method, the destructor is
- // automatically called and cleans up the drawing environment.
- CFocus initiateDrawing(ev, facet);
-
- GetPort(&thePort);
- EraseRect(&thePort->portRect);
-
- TempODShape frameShape = window->GetRootFrame(ev)->AcquireFrameShape(ev, kODNULL);
-
- RgnHandle rgn = frameShape->GetQDRegion(ev);
- bounds = (**rgn).rgnBBox;
- TETextBox(gGlobals->fResultValue, ODISOStrLength(gGlobals->fResultValue), &bounds, teFlushLeft);
- window->Select(ev);
- SOM_CATCH_ALL
- if ( gGlobals->fResultValue )
- {
- ODDisposePtr(gGlobals->fResultValue);
- gGlobals->fResultValue = kODNULL;
- }
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DoErrorDialog
- //
- // Description: This method is called when an OSA error occurs.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__DoErrorDialog
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","DoErrorDialog");
-
- SOM_TRY
- ODSession* session = ODGetSession(ev, _fSelf);
-
- // We must request the Modal focus to prevent multiple modal
- // dialogs from being displayed simultaneously.
-
- if ( session->GetArbitrator(ev)->RequestFocus(ev, gGlobals->fModalFocus, frame) )
- {
- DialogPtr dialog;
- ODSShort itemHit;
-
- // Dim the frontmost document window.
- session->GetWindowState(ev)->DeactivateFrontWindows(ev);
-
- ODSLong savedRef;
- savedRef = BeginUsingLibraryResources();
- {
- dialog = GetNewDialog(kErrorBoxID, kODNULL, (WindowPtr)-1L);
-
- if ( dialog )
- {
- Handle itemHandle;
- Rect itemRect;
- short itemType;
-
- ODISOStr errStr = gGlobals->fOSAScripter->GetErrorMessage(ev);
-
- if ( errStr )
- {
- GetDialogItem(dialog, kErrStrFieldID, &itemType, &itemHandle, &itemRect);
- TempODString string = (ODISOStr)CToPascalString((char*)errStr);
- SetDialogItemText(itemHandle, (unsigned const char*)errStr);
-
- SetCursor(&ODQDGlobals.arrow);
- ModalDialog(kODNULL, &itemHit);
- }
- DisposeDialog(dialog);
- }
- else
- {
- // Could not load error box dialog... something is wrong.
- SysBeep(2);
- }
- }
- EndUsingLibraryResources(savedRef);
-
- // Inform the Arbitrator that we no longer require the Modal focus.
- session->GetArbitrator(ev)->RelinquishFocus(ev, gGlobals->fModalFocus, frame);
-
- // Hilite the frontmost document window.
- session->GetWindowState(ev)->ActivateFrontWindows(ev);
- }
- else
- // If we can't get the modal focus, then another modal dialog is
- // already being displayed.
- SysBeep(2);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: GeometryChanged
- //
- // Description: This method is called when the ExternalTransform or
- // ClipShape of a facet on one of this part's display
- // frames changes.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__GeometryChanged
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFacet* facet,
- ODBoolean clipShapeChanged,
- ODBoolean externalTransformChanged
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","GeometryChanged");
-
- if ( clipShapeChanged )
- // Specifying kODNULL means to invalidate the clipShape (which was
- // calculated from the usedShape).
- facet->Invalidate(ev, kODNULL, kODNULL);
- }
-
- //------------------------------------------------------------------------------
- // Method: InitiateDrag
- // Origin: ScriptRunner
- //
- // Description: Begin the drag transaction on the Result.
- //------------------------------------------------------------------------------
- SOM_Scope ODDropResult
- SOMLINK ScriptRunner__InitiateDrag
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODEventData* event,
- ODFacet* facet,
- ODPoint* where
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","InitiateDrag");
-
- ODDropResult dropResult = kODDropFail;
-
- SOM_TRY
- ODFrame* frame = facet->GetFrame(ev);
-
- // Get the ODDragAndDrop object from the session.
- ODDragAndDrop* dragNdrop = ODGetSession(ev, _fSelf)->GetDragAndDrop(ev);
-
- // Reinitialize the ODDragAndDrop object.
- dragNdrop->Clear(ev);
-
- // Get the Storage Unit where data for dragged objects are going to be written.
- ODStorageUnit* contentSU = dragNdrop->GetContentStorageUnit(ev);
-
- // Write out the text data into the content property.
- // Note: ODSetISOStrProp will add the property and value to the
- // storage unit if it doesn't exist. Otherwise, it will set the
- // focus appropriately.
- ODSetISOStrProp(ev, contentSU, kODPropContents, gGlobals->fTextKind,
- gGlobals->fResultValue);
-
- // Annotate the content storage unit with the frame shape.
- TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
- contentSU->AddProperty(ev, kODPropSuggestedFrameShape);
- frameShape->WriteShape(ev, contentSU);
-
- // Write out the mouse down offset.
- ODSetPointProp(ev, contentSU, kODPropMouseDownOffset, kODPoint, where);
-
- // Initiate the drag.
- TempODPart tempDestPart = kODNULL;
-
- // Get the drag region.
- ODRgnHandle dragRgn = somSelf->CreateDragRegion(ev, facet);
-
- TRY
- // Create byte arrays for dragRgn and refCon (which is the event record).
- TempODByteArray dragRgnBA = CreateByteArray(&dragRgn, sizeof(RgnHandle));
- TempODByteArray eventBA = CreateByteArray(&event, sizeof(ODEventData*)); // event is of type ODEventData*.
-
- ODPart* destPart = kODNULL;
- dropResult = dragNdrop->StartDrag(ev, facet->GetFrame(ev),
- kODDragImageRegionHandle,
- dragRgnBA, &destPart, eventBA);
- // Assign the temp pointer to destPart so it will be
- // released automatically.
- tempDestPart = destPart;
- CATCH_ALL
- DisposeRgn(dragRgn);
- RERAISE;
- ENDTRY
-
- DisposeRgn(dragRgn);
-
- // We don't handle the dropResult since we only allow a copy.
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return dropResult;
- }
-
- //------------------------------------------------------------------------------
- // Method: CreateDragRegion
- // Origin: ScriptRunner
- //------------------------------------------------------------------------------
- SOM_Scope ODRgnHandle
- SOMLINK ScriptRunner__CreateDragRegion
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODFacet* facet
- )
- {
- SampleCode_ScriptRunnerData *somThis = SampleCode_ScriptRunnerGetData(somSelf);
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CreateDragRegion");
-
- ODRgnHandle dragRgn = ODNewRgn();
-
- SOM_TRY
- TempODShape frameShape = facet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
-
- CopyRgn(frameShape->GetQDRegion(ev), dragRgn);
-
- // Inset the region and subtract it from the original.
- {
- ODRgnHandle insetRgn = ODNewRgn();
-
- CopyRgn(dragRgn, insetRgn);
- InsetRgn(insetRgn, 1, 1);
- DiffRgn(dragRgn, insetRgn, dragRgn);
-
- ODDisposeHandle((ODHandle)insetRgn);
- }
-
- // Put the region in global coordinates.
- {
- CFocus forMapping(ev, facet);
-
- Point localToGlobalTrans = { 0, 0 };
- LocalToGlobal(&localToGlobalTrans);
- OffsetRgn(dragRgn, localToGlobalTrans.h, localToGlobalTrans.v);
- }
- SOM_CATCH_ALL
- ODDisposeHandle((ODHandle)dragRgn);
- dragRgn = kODNULL;
- SOM_ENDTRY
-
- return dragRgn;
- }
-
- //=======================================================================
- //
- // Unimplemented Methods • Unimplemented Methods • Unimplemented Methods
- //
- //=======================================================================
-
- //------------------------------------------------------------------------------
- // Method: ReadPartInfo
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope ODInfoType
- SOMLINK ScriptRunner__ReadPartInfo( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFrame* frame, ODStorageUnitView* storageUnitView )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ReadPartInfo");
-
- return kODNULL;
- }
-
- //------------------------------------------------------------------------------
- // Method: WritePartInfo
- // Origin: ODPart
- //
- // Description: When a frame is being externalized by the Draft, it will ask the
- // owner (part) to write out its info annotation on the frame.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__WritePartInfo( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODInfoType partInfo, ODStorageUnitView* storageUnitView )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","WritePartInfo");
- }
-
- //------------------------------------------------------------------------------
- // Method: ClonePartInfo
- // Origin: ODPart
- //
- // Description: When a frame is being cloned by the Draft, it will ask the owner
- // (part) to clone its info annotation on the frame.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ClonePartInfo( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODDraftKey key, ODInfoType partInfo,
- ODStorageUnitView* storageUnitView, ODFrame* scopeFrame )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ClonePartInfo");
- }
-
- //------------------------------------------------------------------------------
- // Method: ContainingPartPropertiesUpdated
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ContainingPartPropertiesUpdated(SampleCode_ScriptRunner *somSelf,
- Environment *ev, ODFrame* /*frame*/, ODStorageUnit* /*propertyUnit*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ContainingPartPropertiesUpdated");
- }
-
- //------------------------------------------------------------------------------
- // Method: FrameShapeChanged
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame's shape being
- // altered, either by the user or the part we are embedded in.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__FrameShapeChanged( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFrame* frame )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","FrameShapeChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: PresentationChanged
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__PresentationChanged(SampleCode_ScriptRunner *somSelf,
- Environment *ev, ODFrame* /*frame*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","PresentationChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: SequenceChanged
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__SequenceChanged(SampleCode_ScriptRunner *somSelf,
- Environment *ev, ODFrame* /*frame*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","SequenceChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: FacetAdded
- // Origin: ODPart
- //
- // Description: This method is called when any part adds a facet to
- // one of our display frames.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__FacetAdded( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFacet* facet )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","FacetAdded");
- }
-
- //------------------------------------------------------------------------------
- // Method: FacetRemoved
- // Origin: ODPart
- //
- // Description: This method is called when any part removes a facet from
- // one of our display frames.
- //
- // The part just removes the "active" flag from the appropriate
- // display frame if necessary since this facet will not be
- // available, or active, again.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__FacetRemoved( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFacet* facet )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","FacetRemoved");
- }
-
- //------------------------------------------------------------------------------
- // Method: AttachSourceFrame
- // Origin: ODPart
- //
- // Description: If a part which we are contained in is opened into a part
- // window, it is required to iterate over its embedded frames and
- // add new display frames in the part window. After each new
- // embedded frame is created, this method will be called.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__AttachSourceFrame( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFrame* frame, ODFrame* sourceFrame )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","AttachSourceFrame");
- }
-
-
- //------------------------------------------------------------------------------
- // Method: AdjustMenus
- // Origin: ODPart
- //
- // Description: This method is called when a kODEvtMouseDown event
- // occurs in the menubar and the part owns the menu
- // focus. The part enables the appropriate items for its current
- // state and updates the menu items.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__AdjustMenus( SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFrame* frame )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","AdjustMenus");
- }
-
- //------------------------------------------------------------------------------
- // Method: CanvasChanged
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__CanvasChanged(SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFacet* /*facet*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CanvasChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: CanvasUpdated
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__CanvasUpdated(SampleCode_ScriptRunner *somSelf, Environment *ev,
- ODCanvas* /*canvas*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","CanvasUpdated");
- }
-
- //------------------------------------------------------------------------------
- // Method: HighlightChanged
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__HighlightChanged(SampleCode_ScriptRunner* somSelf,
- Environment* ev, ODFacet* /*facet*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","HighlightChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: GetPrintResolution
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope ODULong
- SOMLINK ScriptRunner__GetPrintResolution(SampleCode_ScriptRunner *somSelf,
- Environment *ev, ODFrame* /*frame*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","GetPrintResolution");
- return 72;
- }
-
- //------------------------------------------------------------------------------
- // Method: LinkStatusChanged
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__LinkStatusChanged(SampleCode_ScriptRunner *somSelf,
- Environment *ev, ODFrame* /*frame*/)
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","LinkStatusChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: ExternalizeKinds
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ExternalizeKinds
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODTypeList* kindset
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ExternalizeKinds");
- }
-
- //------------------------------------------------------------------------------
- // Method: ChangeKind
- // Origin: ODPart
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK ScriptRunner__ChangeKind
- (
- SampleCode_ScriptRunner* somSelf,
- Environment* ev,
- ODType kind
- )
- {
- SampleCode_ScriptRunnerMethodDebug("ScriptRunner","ChangeKind");
- }
-